<?php
header('Content-Type: text/html; charset=UTF-8');

require 'utf8.php';
require 'database.php';
$db = new DB();

$Qry = 'SELECT g.id, g.name, g.image_up, g.url, d.infomation, d.howtoplay
		FROM _games g
		INNER JOIN games_description d ON (g.id = d.id)
		ORDER BY id ASC';

$res = $db->fetchAll($Qry);

foreach ($res as $key=>$row) {
	$name = str_replace('_', ' ', $row['name']);
	$name = str_replace("'", '&#39;', $name);
	$name = trim($name);
	$url = remove_unicode($row['name'], true);

	$desc = strip_tags($row['infomation'], 'br');
	$desc = str_replace('&nbsp;', ' ', $desc);
	$desc = str_replace("'", '&#39;', $desc);
	$desc = trim($desc);

	$howto = strip_tags($row['howtoplay'], 'br');
	$howto = str_replace('&nbsp;', ' ', $howto);
	$howto = str_replace("'", '&#39;', $howto);
	$howto = trim($howto);

	$data = array(
			'g_name'=>$name,
			'g_url'=>$url,
			'object'=>trim($row['url']),
			'images'=>$row['image_up'],
			'description'=>$desc,
			'howto'=>$howto,
			'category'=>'girls',
			'tags'=>'frozen',
// 			'active'=>0,
			'updated'=>(time() + rand(10, 99))
	);

// 	$newID = $db->insert('games', $data);

	if ($newID)
		echo ($key+1) . ': ' . $name . '<br />';
}